//
//	File: OyEngine.h
//

#ifndef OY_ENGINE_H
#define OY_ENGINE_H

#define OY_OK                        S_OK
// just reports no errors
#define OY_CANCELED                  0x02000001
// generell error message
#define OY_FAIL                      0x82000001

#define OY_CREATEAPI                 0x82000002
#define OY_CREATEDEVICE              0x82000003
#define OY_CREATEBUFFER              0x82000004
#define OY_INVALIDPARAM              0x82000005
#define OY_INVALIDID                 0x82000006
#define OY_BUFFERSIZE                0x82000007
#define OY_BUFFERLOCK                0x82000008
#define OY_NOTCOMPATIBLE             0x82000009
#define OY_OUTOFMEMORY               0x8200000a
#define OY_FILENOTFOUND              0x8200000b
#define OY_INVALIDFILE               0x8200000c
#define OY_NOSHADERSUPPORT           0x8200000d


// Class Forward Declare
class OyVector4D;
class OyMatrix;
class OyPlane;

enum OY_DRAWFONT_FLAG
{
	OY_DRAWTEXT_DEFAULT		= 0,
	OY_DRAWTEXT_SHADOW		= 1 << 1,



	OY_DRAWTEXT_MASK = OY_DRAWTEXT_SHADOW,
};
/////////////////////////////////////////////////////////////////////////////

// Vertex struct
typedef enum OYVERTEXID_TYPE
{
	VID_UPOS,			// untransformed position only
	VID_UNORCOLTEX,		// untransformed pos + normal + VertexColor + one texture coord
	VID_UTEX,			// untransformed and no color vertex
	VID_UCOLOR,			// untransformed and with color vertex
	VID_ANIM,			// used for character animation
	VID_THREETEX,		// three texture coord pairs
	VID_UTAN,			// like VID_UTEX but with tangent vector
	VID_FONT			// transformed pos + color vertex + one texcoord
} OY_VERTEXTYPE;

// untransformed vertex
struct OY_UPOS_VERTEX_TYPE 
{
	float  x, y, z;
};

// untransformed pos + normal + VertexColor + one texture coord
struct OY_UNORMALCOLORTEX_VERTEX_TYPE
{
	float  x, y, z;
	float  vcNormal[3];
	DWORD  VertexColor;
	float  tu, tv;
};

// untransformed vertex only with one tex coord and normal 
struct OY_UTEX_VERTEX_TYPE 
{
	float  x, y, z;
	float  vcNormal[3];
	float  tu, tv;
};

// untransformed vertex only with vertex color and one tex coord
struct OY_UCOLOR_VERTEX_TYPE
{
	float  x, y, z;
	DWORD  VertexColor;
	float  tu, tv;
};

// used for character animation (one vertex with two bone weights)
struct OY_ANIM_VERTEX_TYPE
{
	float  x, y, z;
	float  vcNormal[3];
	float  tu, tv;
	DWORD  dwBlendWeightIndices;
};

// three texture coord pairs
struct OY_THREETEX_VERTEX_TYPE
{
	float  x, y, z;
	float  vcNormal[3];
	float  tu0, tv0;
	float  tu1, tv1;
	float  tu2, tv2;
};

//untransformed vertex only with one tex coord and normal plus tangent vector
struct OY_UTAN_VERTEX_TYPE
{
	float  x, y, z;
	float  vcNormal[3];
	float  tu, tv;
	float  vcU[3];
};

struct OY_FONT_VERTEX_TYPE
{
	float  x, y, z, w;
	DWORD  VertexColor;
	float  tu, tv;
};

/////////////////////////////////////////////////////////////////////////////
typedef enum OYLIGHTID_TYPE
{
	LGT_DIRECTIONAL,	// directional light source
	LGT_POINT,			// point light source
	LGT_SPOT			// spot light source
} OY_LIGHTTYPE;

typedef enum OYCAMERAMODE_TYPE
{
	EMD_PERSPECTIVE,    // perspective projection
	EMD_ORTHOGONAL,     // orthogonal projection
	EMD_TWOD            // world coords equal to screen coords (2D mode)
} OY_CAMERAMODE;

typedef enum OYAXIS_TYPE
{ 
	X_AXIS,
	Y_AXIS, 
	Z_AXIS 
} OY_AXIS;


typedef struct OYVIEWPORT_TYPE
{
	DWORD X;
	DWORD Y;  
	DWORD Width;
	DWORD Height;
	OYVIEWPORT_TYPE()
	{ X = Y = Width = Height = 0; }
} OY_VIEWPORT;


// generic skin type
typedef struct OYSKIN_TYPE
{
	bool		  bAlpha;			// needs alphablending enabled
	bool		  bAlphaTest;		// opaque but need alpha-test
	char		  nPrimitiveType;	// D3DPRIMITIVETYPE (D3DPT_TRIANGLELIST = 4)
	unsigned int  nMaterialID;		// ID to material in SkinManager
	unsigned int  nTextureID[8];	// ID to up to 8 textures in SkinManager

	OYSKIN_TYPE() : bAlpha(false), bAlphaTest(false), nPrimitiveType(4), nMaterialID(0xFFFFFFFF)
	{
		for(int i=0; i<8; i++)
			nTextureID[i] = 0xFFFFFFFF;
	}
} OySkin;

// generic color type
typedef struct OYCOLOR_TYPE 
{
	union 
	{
		struct 
		{
			float fR;
			float fG;
			float fB;
			float fA;
		};
		float c[4];
	};
	OYCOLOR_TYPE() { fR = fG = fB = fA = 0.0f; }
	OYCOLOR_TYPE(float r, float g, float b, float a) : fR(r), fG(g), fB(b), fA(a) { }
} OyColor;

// material type
typedef struct OYMATERIAL_TYPE
{
	OyColor cDiffuse;   // RGBA diffuse light value
	OyColor cAmbient;   // RGBA ambient light value
	OyColor cSpecular;  // RGBA specular light value
	OyColor cEmissive;  // RGBA emissive light value
	float   fPower;     // specular power

	OYMATERIAL_TYPE() : cDiffuse(1,1,1,1), cAmbient(1,1,1,1), cSpecular(0,0,0,0), cEmissive(0,0,0,0), fPower(0)
	{		
	}

} OyMaterial;


// texture type
typedef struct OYTEXTURE_TYPE 
{
	TCHAR    *chName;    // texture filename
	void     *pData;     // texture data
	OYTEXTURE_TYPE() { chName = NULL; pData = NULL; }
} OyTexture;




#endif